package routers

import (
	"software/api"
	"software/middleware"

	"github.com/gin-gonic/gin"
)

func (RouterGroup) PostsRouter(router *gin.Engine) {
	// 创建服务实例

	postsApi := api.ApiGroupApp.PostApi
	// 使用api路由组
	api := router.Group("posts")

	{
		api.Use(middleware.JWTMiddleware())
		// 获取所有帖子列表
		api.GET("", postsApi.GetPostList)
		// 获取所有帖子详细内容
		api.GET("/list", postsApi.GetAllPostsWithDetails)
		// 获取帖子详情
		api.GET("/:id", postsApi.GetPostDetail)
		// 审核指定帖子
		api.POST("/:id/audit", postsApi.AuditPost)
		//更新帖子状态
		api.POST("/status", postsApi.UpdatePostsStatus)
		// 删除帖子
		api.DELETE("/:id", postsApi.DeletePost)
	}
}
